﻿@using ETD.WebOrganization.Libs.Helper;
@using ETD.WinClient.Config;

@if (BaseConfig.Current.IsShowDebugTool)
{
    <div id="debugRootPanel" style="position:fixed;top:30%;left:0px;z-index:10000;">
        <button id="btnShowDebugInfo">
            调试
        </button>
        <button id="btnCloseDebugInfo" style="display:none;">
            关闭
        </button>
        <div id="debugInfoPanel" style="height:300px;width:100%;overflow:scroll;display:none;background-color:snow;">
        </div>
    </div>
}



<script type="text/javascript">

    var isDebugInfoPanelShow = false;
    var IsOpenDebugToolAlert=@BaseConfig.Current.IsOpenDebugToolAlert.ToString().ToLower();
    $(function () {
        $("#btnShowDebugInfo").bind("click", function () {
            var debugInfoPanel = $("#debugInfoPanel");
            if (isDebugInfoPanelShow) {
                isDebugInfoPanelShow = false;
                debugInfoPanel.hide();
                $("#btnCloseDebugInfo").hide();
                $("#debugRootPanel").width("0%");
            }
            else {
                isDebugInfoPanelShow = true;
                debugInfoPanel.show();
                $("#btnCloseDebugInfo").show();
                $("#debugRootPanel").width("100%");
            }
        });
        $("#btnCloseDebugInfo").bind("click", function () {
            $("#btnShowDebugInfo").hide();
            $("#debugRootPanel").hide();
        });

    });

    var DebugTool = {
        WriteLine: function (log) {
            var debugInfoPanel = $("#debugInfoPanel");
            debugInfoPanel.html(debugInfoPanel.html() + "<div>" + log + "</div>");
            console.log(log);
        },
        Alert: function (log) {
            DebugTool.WriteLine(log);
            if(IsOpenDebugToolAlert){
                alert(log);
            }
        }
    };
</script>